package cn.geracomium.action;

import cn.geracomium.util.action.AbstractAction;
import cn.geracomium.util.web.page.PageResult;
import cn.gov.service.IAccountManageService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/pages/account/")
public class AccountListAction extends AbstractAction {

    @Reference
    private IAccountManageService accountManageService;

    @RequestMapping("list")
    public String listPre(){
        return "pages/files/account/account_list";
    }

    @RequestMapping("list_search")
    public ModelAndView list() {
        ModelAndView mav = new ModelAndView("pages/files/account/account_list");
        PageResult pr = new PageResult();
        Map<String, Object> result = new HashMap<>();
        try {
            result = accountManageService.listPre(pr.getKeyWord(), pr.getEmpType(), pr
                    .getEmpStatus(), pr.getBeginDate(), pr
                    .getEndDate(), pr.getPageNum(), pr.getPageSize());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(pr.getEmpType());
        mav.addAllObjects(result);
        mav.addObject(pr) ;
        return mav;
    }

    @RequestMapping("initPassword")
    @ResponseBody
    public Object initPassword(Long accountId) {
        return accountManageService.editInitPassword(accountId) ;
    }

}



